﻿using System;
using System.Collections.Generic;
using System.IO;

namespace Utility
{
    public class PicInfo
    {
        //图片全路径
        private string _fullName;
        //图片名称
        private string _nameNoExtension;

        public PicInfo(string path)
        {
            _fullName = path;
            _nameNoExtension = Path.GetFileNameWithoutExtension(path);
        }

        public string FullName{
            get { return _fullName; }
            set
            {
                if (value != "")
                    _fullName = value;
            }
        }
        public string NameNoExtension
        {
            get { return _nameNoExtension; }
            set
            {
                if (value != "" && value.IndexOf('.') == -1)
                    _nameNoExtension = value;
            }
        }
        public string GetExtension()
        {
            return Path.GetExtension(_fullName);
        }
        public static bool IsImage(string path)
        {
            string ext = Path.GetExtension(path);
            if (ext.ToLower() == ".bmp" || ext.ToLower() == ".jpg" || ext.ToLower() == ".gif" || ext.ToLower() == ".jpeg")
                return true;
            else
                return false;
        }
        public override string ToString()
        {
            return _fullName;
        }
    }
}
